Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTP-1382 GMAP Push notifications for leg transition #275

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from

Conversation

br648
Copy link
Contributor

@br648 br648 commented Dec 3, 2024

Checklist

  • Appropriate branch selected (all PRs must first be merged to dev before they can be merged to master)
  • Any modified or new methods or classes have helpful JavaDoc and code is thoroughly commented
  • The description lists all applicable issues this PR seeks to resolve
  • The description lists any configuration setting(s) that differ from the default settings
  • All tests and CI builds passing

Description

Check for upcoming leg transitions (arrive, departure & mode change) and notify observers.

@br648 br648 changed the title Check trip for major changes OTP-1382 Check trip for major changes Dec 5, 2024
Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify the intent behind origin/destination change? I think what we want to do is to notify observers that someone has departed or arrived on their trip.

@br648
Copy link
Contributor Author

br648 commented Dec 5, 2024

Could you clarify the intent behind origin/destination change? I think what we want to do is to notify observers that someone has departed or arrived on their trip.

Oh, really! I thought I was to check the OTP response for any changes to the traveler's trip and notify them of this. Could I have a couple of use cases just to clarify what is expected please?

@binh-dam-ibigroup
Copy link
Collaborator

Oh, really! I thought I was to check the OTP response for any changes to the traveler's trip and notify them of this. Could I have a couple of use cases just to clarify what is expected please?

It is simpler than you think it is. Basically, a notification when the traveler leaves the origin or arrives at destination, and when the traveler changes modes (arrives at a bus stop, gets off the bus, gets on/off the bike if there is a bike involved).

@binh-dam-ibigroup
Copy link
Collaborator

Basically, a notification when the traveler leaves the origin

Notifications are for observers who are not traveling with the traveler and their companion.

Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make these changes please:

  • convert the departure/arrival change notification into leaving the origin/arriving at destination notifications, and send the notification when the traveler gets to the corresponding location.
  • execute mode change notification when approaching the end of a leg where the next leg has a different mode.

@br648 br648 changed the title OTP-1382 Check trip for major changes OTP-1382 GMAP Push notifications for leg transition Dec 10, 2024
@br648 br648 assigned binh-dam-ibigroup and unassigned br648 Dec 10, 2024
Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic is getting there. I don't think we need to identify/process a list of notification types (one should be fine). Notifications are for the observers and non-trip-initiators, and there are language tweaks.

@@ -19,10 +19,10 @@ public enum Message {
ACCEPT_DEPENDENT_EMAIL_SUBJECT,
ACCEPT_DEPENDENT_EMAIL_MANAGE,
ACCEPT_DEPENDENT_ERROR,
ARRIVED_AND_MODE_CHANGE_NOTIFICATION,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say just keep the old name MODE_CHANGE_NOTIFICATION.

Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you address duplicate notifications still being sent, please?

}

/**
* Create locale specific notifications.
* If a traveler is on schedule and on either a walk or transit leg check for possible leg transition notification.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant to say "If a traveler is on the route (not deviated)"...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert comma before "check".

}

/**
* Depending on the traveler's proximity to the start/end of a leg return the appropriate notification type.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert comma before "return".


private static Stream<Arguments> createLegTransitionNotificationTestCases() throws Exception {
String travelerName = "Obi-Wan";
Locale locale = Locale.US;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove locale as a test parameter (set that in the test itself).

@@ -559,6 +592,9 @@ private void sendNotifications() {
// TODO: better handle below when one of the following fails
if (successEmail || successPush || successSms) {
notificationTimestampMillis = DateTimeUtils.currentTimeMillis();
// Prevent repeated notifications by saving successfully sent notifications.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is at the wrong spot, I see duplicate notifications being sent and recorded (see screenshot)

image

Comment on lines +132 to +133
if (isAtStartOfLeg(travelerPosition)) {
return DEPARTED_NOTIFICATION;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Change the condition so that departing notifications are sent at the beginning of the trip only.

I found one case where I set two coordinates, one close to the end of a leg, and the next one close to the beginning of the next leg, and I got two companion notifications, one for arriving at the end of the previous leg, and one for departing the next leg, which is redundant with the previous one and is thus unneeded noise. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for consistency we leave it as is. The observer would get a notification that the traveler has arrived but not one to tell them they have departed. The next notification would be the traveler arriving at the end of the next leg. Correct?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I observed.

Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the changes are working and code looks good. The nice-to-have tweak is not blocking.

@@ -4,7 +4,10 @@ ACCEPT_DEPENDENT_EMAIL_LINK_TEXT = Accepter la demande
ACCEPT_DEPENDENT_EMAIL_SUBJECT = Demande d'accompagnateur
ACCEPT_DEPENDENT_EMAIL_MANAGE = G�rez vos pr�f�rences
ACCEPT_DEPENDENT_ERROR = La demande d'accompagnateur n'a pas �t� re�ue.
ARRIVED_NOTIFICATION = TODO %s.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@binh-dam-ibigroup can you provide the french messages please!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui ! 36b26af

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants